import {Space} from "antd";
import {invoke} from '@tauri-apps/api/core';
import {useEffect, useState} from "react";
import {ProTable} from '@ant-design/pro-components';

const LargePage = (props = {}) => {
    const columns = [
        {
            title: '文件名称',
            dataIndex: 'path',
            key: 'path',
            ellipsis: true,
        },
        {
            title: '大小',
            dataIndex: 'size',
            key: 'size',
            width: 80,
        },
        {
            title: '操作',
            width: 65,
            key: 'op',
            align: 'center',
            search: false,
            render: (text, row) => {
                return <Space><a>删除</a></Space>
            }
        },
    ];
    const [listData, setListData] = useState([]);
    useEffect(() => {
    }, []);
    const getList = () => {
        if (props.paths) {
            return invoke("find_large_file", {paths: props.paths}).then(res => {
                return {data: res, success: true}
            })
        }
    }
    const rowSelection = {
        onChange: (selectedRowKeys, selectedRows) => {
            console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        },
    };
    return (
        props?.show?
        <ProTable
            size={"small"}
            // bordered={true}
            search={false}
            options={false}
            pagination={false}
            columns={columns}
            rowSelection={{
                ...rowSelection,
            }}
            request={getList}
        >
        </ProTable>:null
    )
}

export default LargePage